// hyb_menzhen/detail/pages/doctor_detail/doctor_detail.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    type_index: 0,
    type: ["医生简介", "患者口碑"],
    did: "",
    types: "",
    id: "",
    page: 0,
    pingjia: []
  },
  bindtype(e) {
    this.setData({
      type_index: e.currentTarget.dataset.index
    })
  },
  bindall(e) {
    this.setData({
      type_index: 1
    })
  },
  // 展开
  bindsc(e) {
    this.setData({
      sc_show: !this.data.sc_show
    })
  },
  bindjj(e) {
    this.setData({
      jj_show: !this.data.jj_show
    })
  },
  // 医馆看诊
  bindyiguan(e) {
    // did=1&server=yuyuejiuzhen&money=11.00&hid=30&keshi_two=100&tid=32&leixing=lvtong&name=预约就诊&zid=
    var that = this;
    var server = that.data.server;
    wx.navigateTo({
      url: '/hyb_yl/zhuanjiasubpages/pages/jiuzhen_date/jiuzhen_date?zid=' + that.data.zid + '&server=' + that.data.server + '&money=' + that.data.money + '&hid=' + that.data.hid + '&week=' + e.currentTarget.dataset.week + '&time=' + e.currentTarget.dataset.time,
    })

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // inquiry=1&zid=90&server=yuanchengguahao&money=0.10
    var that = this;
    var zid = options.zid;
    var server = options.server;
    var money = options.money

    that.setData({
      server: server,
      money: money,
      zid: zid,
      bgc: wx.getStorageSync('color')
    })
    // 获取客服详情
    that.getZhuanjia();
    that.getPingjia();
  },
  getZhuanjia: function (res) {
    var that = this;
    app.util.request({
      'url': "entry/wxapp/zhuanjia.zhuanjia_detail",
      data: {
        zid: that.data.zid
      },
      success: function (res) {
        that.setData({
          info: res.data
        })
      }
    })
  },
  getPingjia: function () {
    var that = this;
    app.util.request({
      'url': "entry/wxapp/green.getPingjia",
      data: {
        page: that.data.page,
        zid: that.data.zid,
      },
      success: function (res) {
        var page = that.data.page + 1;
        that.setData({
          page: page,
          pingjia: that.data.pingjia.concat(res.data)
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    if (this.data.type_index == 1) {
      that.getPingjia();
    }
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})